<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
Object obj=request.getSession().getAttribute("role_resource");
if(null==obj){
	response.setStatus(1000);
	return;
}
%>
    
	<script type="text/javascript">
	
		//功能树数据源
		var tree_store = new Ext.data.JsonStore({
    		root: "data",
    		totalProperty: "total",
    		fields: ["id","text","leaf"],
    		url: "tree!function.action"
    	});
		//功能列表数据源
		var data_store = new Ext.data.JsonStore({
    		root: "data",
    		totalProperty: "total",
    		fields: ["id","name","level","url","remark","parent","state"],
    		url: "func!list.action"
    	});
    	//页面初始化
		
			
		//定义数据显示面板
		var p1 = {
			id: "p1",
			xtype: "grid",
			region: "center",
			stripeRows:true,
			loadMask : true,//在加载数据时遮罩住元素,替换元素Updater的加载提示器，并且在初始化加载之后销毁
			autoExpandColumn:"remark",//自动填充
			autoExpandMin : 100,//自动填充最小宽度
			//height:"100%",
			store: data_store,
			columns:[
    	    	{header: "功能编号",		dataIndex: "id",	menuDisabled: true},
   				{header: "功能名称",		dataIndex: "name",	menuDisabled: true},
   				{header: "URL",			dataIndex: "url",	menuDisabled: true},
   				{header: "备注",			dataIndex: "remark",	id: "remark",	menuDisabled: true}
			],
			bbar: new Ext.ux.PagingToolbar({
   	        	pageSize: limit,
   	        	store: data_store
   	    	})
		};
		
	var fun_pel = new Ext.Panel({
		id: "panel",
		border : false, 
		layout: "border",
		items: [{
			id:"funcTree",
			xtype:"billTreePanel",
			dataUrl:"tree!function.action",
			autoScroll: true,
			root: new Ext.tree.AsyncTreeNode({
				id: "root",
				expanded: true
			}),
			listeners: {
				"click": function(node){
					tree_store.load({params:{node:node.attributes.id}});
					data_store.baseParams = data_store.baseParams || {};
					if(node.isLeaf()) {
						data_store.baseParams["func.id"] = node.attributes.id;
						delete data_store.baseParams["func.parent"];
					} else {
						delete data_store.baseParams["func.id"];
						data_store.baseParams["func.parent"] = node.attributes.id;
					}
					data_store.load({params:{start : 0,limit : limit}});
				}
			}},p1]
	});	
	
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(fun_pel);
	CenterPanel.doLayout();
	</script>
    
